// 导入 Sequelize 和数据库连接配置
const { DataTypes } = require('sequelize');
const { sequelize } = require('../init'); // 导入数据库连接配置

// 创建主菜单表模型
const MainMenu = sequelize.define('MainMenu', {
    MenuID: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        allowNull: false
    },
    MenuName: {
        type: DataTypes.STRING,
        allowNull: false,
        collate: 'utf8mb4_bin'
    },
    Icon: {
        type: DataTypes.STRING,
        collate: 'utf8mb4_bin'
    },
    URL: {
        type: DataTypes.STRING,
        collate: 'utf8mb4_bin'
    },
    HasChild: {
        type: DataTypes.INTEGER,
        allowNull: false
    },
    Order: {
        type: DataTypes.INTEGER
    },
    CreatedAt: {
        type: DataTypes.DATE,
        allowNull: true
    },
    UpdatedAt: {
        type: DataTypes.DATE,
        allowNull: true
    }
}, {
    tableName: 'mainmenu',
    timestamps: false,
    collate: 'utf8mb4_bin'
});

// 帮我打印一下数据库连接情况
MainMenu.sync({ force: false }).then(() =>
{
    console.log('主菜单表准备');
});

module.exports = { MainMenu };